<? 
	if($user_idx=="")
	{

?>
		<!-- 상단메뉴:비로그인 시작-->

		<div id="top-menu-wrapper">
            <div id="top-menu">
				<div id="logo"><img src='img/logo_ndd.png'></div>
	
				<div style="position:absolute;top:12px;left:880px;width:72px;height:28px;cursor:pointer;">
					<span>
						<a href='login.php'>
							<img src='./img/button_login.png' alt='login' border='0'/>
						</a>
					</span>
				</div>

			</div>
		</div>
		<div id="menu_bg">
		</div>

		<!-- 상단메뉴:비로그인 끝-->
<?
	}
	else
	{
?>
		
		<!-- 상단메뉴:로그인 되었을 때 시작-->
        <div id="top-menu-wrapper">
            <div id="top-menu">
				<div id="logo"><img src='img/logo_ndd.png'></div>
                <a href="ndd_cure.php"><div id="top-menu-1" onmouseover='top_menu_over(1);' onmouseout='top_menu_out(1);'>
					<div id='top_menu_1_box' style='position:absolute;left:266px;top:40px;width:68px;height:42px;display:none;'>
						<img src='img/redbox_cure.png'>
					</div>
				</div></a>
				
                <a href="hospital.php"><div id="top-menu-2" onmouseover='top_menu_over(2);' onmouseout='top_menu_out(2);'>
					<div id='top_menu_2_box' style='position:absolute;left:311px;top:40px;width:68px;height:42px;display:none;'>
						<img src='img/redbox_hospital.png'>
					</div>
				</div></a>

                <a href="ndd_talk.php?name=talk_ra"><div id="top-menu-3" onmouseover='top_menu_over(3);' onmouseout='top_menu_out(3);'>
					<div id='top_menu_3_box' style='position:absolute;left:358px;top:40px;width:68px;height:42px;display:none;'>
						<img src='img/redbox_talk.png'>
					</div>
				</div></a>
				<!--div id="search-box-wrapper">
                    <input type="text" id="search-box" />
				</div-->
                <a href="ndd_cure_drug.php"><div id="top-menu-4" onmouseover='top_menu_over(4);' onmouseout='top_menu_out(4);'>
					<div id='top_menu_4_box' style='position:absolute;left:435px;top:40px;width:68px;height:42px;display:none;'>
						<img src='img/redbox_input.png'>
					</div>
				</div></a>
                <a href="5_1.php"><div id="top-menu-5" onmouseover='top_menu_over(5);' onmouseout='top_menu_out(5);'>
					<div id='top_menu_5_box' style='position:absolute;left:480px;top:40px;width:68px;height:42px;display:none;'>
						<img src='img/redbox_chart.png'>
					</div>
				</div></a>

				<!-- 메뉴 텍스트 박스 출력 시작-->
				<script>
				function top_menu_over(i){
					$('#top_menu_'+i+'_box').show();

				}
				function top_menu_out(i){
					$('#top_menu_'+i+'_box').hide();

				}
				</script>
				<!-- 메뉴 텍스트 박스 출력 끝-->

				<!--div style='padding-top:18px;padding-left:20px;float:right;'>
		            <a href='ndd_member_info.php'><img src='images/modify_icon_m.png' border='0'/></a>&nbsp;
	                <a href='logout.php'><img src='images/logout_icon_m.png' border='0'/></a>
				</div-->

                <div id="top-right-menu-wrapper">

                    <a href="memo.php"><div id="top-right-menu-1">

						<!-- 쪽지 수 출력-->
							<?
									$sql ="
										SELECT count(memo_idx) FROM ndd_memo WHERE target_idx = $user_idx AND read_timestamp = '0000-00-00 00:00:00' LIMIT 1;
									";

									$result = mysql_query($sql,$connect);

									$row = mysql_fetch_row($result);

									if($row[0]>0)
									{
										?>
										<div class="right-count">
										<?=$row[0]?>
										</div>
										<?
									}
							?>
						<!-- 쪽지 수 출력 끝-->		
						

					</div></a>

					<!-- 퀘스트 페이지 연결 해제 -->
                    <!--a href="#"><div id="top-right-menu-2"><div class="right-count">2</div></div></a-->
                    
					
					
					<div id="top-right-menu-3" onmouseover='top_menu_over(8);' onmouseout='top_menu_out(8);'>

						<!-- 친구 소식 count 출력-->
							<?
								/*
									$sql ="
										SELECT count(memo_idx) FROM ndd_memo WHERE target_idx = $user_idx AND read_timestamp = '0000-00-00 00:00:00' LIMIT 1;
									";

									$result = mysql_query($sql,$connect);

									$row = mysql_fetch_row($result);

									if($row[0]>0)
									{
										echo "<div class="right-count">".$row[0]."</div>";
									}
								*/
							?>
						<!-- 친구 소식 count 출력 끝-->		
						<div id='top_menu_8_box' style="position:absolute;left:727px;top:40px;width:264px;height:166px;display:none;background-image:url('img/account_popup_bg.png');">
							<div style='position:absolute;left:22px;top:31px;height:56px;width:56px;'>
								<img src='<?
								if(file_exists("./upload/member_photo/".$user_idx))
								{
									echo "./upload/member_photo/".$user_idx;
								}
								else
								{
									echo "img/account_popup_image_bg.png";
								}
								?>' width='56px' height='56px'>

							</div>
							<div style='position:absolute;left:95px;top:28px;height:94px;width:163px;text-align:left;'>
								<span id='article_content' >
						<?
								
									$sql ="
										SELECT nickname FROM ndd_user WHERE user_idx = $user_idx LIMIT 1;
									";

									$result = mysql_query($sql,$connect);

									$row = mysql_fetch_row($result);

									echo $row[0];

							?>
								</span><br>
								<a href="friends.php"><font color='#000'>친구관리</font></a><br>
								<a href='ndd_member_info.php'><font color='#000'>계정관리</font></a>
							</div>
							<div style='position:absolute;left:22px;top:133px;height:20px;width:163px;text-align:left;'>
								<a href='logout.php'><font color='#000'>로그아웃</font></a>
							</div>

						</div>

					</div>

                </div>
				
		

			</div>
		</div>
		<div id="menu_bg">
		</div>
		
		<!-- 상단메뉴:로그인 되었을 때 끝-->

<?
	}
?>



		<!-- 개인 팝업 메뉴-->
			<div style='position:absolute; top:10px; left:10px; padding:0px; z-index:99;width:410px;height:260px; display:none;' id='div_user'>
				<div id='div_user_menu' style="display:none;width:410px;height:260px;background-image:url('./img/popup_message_bg.png');">

					<br/><br/><br/><br/><br/>
					<p align='center'>
					<span id="article_content">
						<a onclick="move_my_info();" style='cursor:pointer;'>
						'<span id='memo_target_name_1'>dd</span>'님의 건강정보 보기</a><br>
						<br>
						'<a onclick="$('#memo_new_content').val('');$('#div_memo_new').show();$('#div_user_menu').hide();" style='cursor:pointer;'><span id='memo_target_name_2'>dd</span>'님에게 쪽지 보내기</a><br>
					</span>
					</p>



					<!-- 닫기버튼-->
					<div style="position:absolute;left:370px;top:0px;width:40px;height:40px;cursor:pointer;" onclick="$('#div_user').hide();"><span></span></div>					
				</div>
				<div id='div_memo_new' style="display:none;width:410px;height:260px;background-image:url('./img/popup_message_bg.png');">

					<div style="position:absolute;left:31px;top:48px;width:300px;height:20px;"><span id="article_content">
					'<span id='memo_target_name_3'>dd</span>'님께 보내는 쪽지
					</span></div>

					<div style="position:absolute;left:31px;top:77px;width:350px;height:115px;">
					<textarea style='width:350px;height:115px;' id='memo_new_content'></textarea>
					</div>


					<input type='hidden' id='memo_new_target_idx'>

					<div style="position:absolute;left:31px;top:205px;width:350px;height:115px;">
						<a onclick='memo_send();' style='cursor:pointer;'>
						<img src='./img/popup_message_btn_2.png' border=0>
						</a>
					</div>

					<div style="position:absolute;left:111px;top:205px;width:350px;height:115px;">
						<a onclick="$('#div_user').hide();" style='cursor:pointer;'>
						<img src='./img/popup_message_btn_1.png' border=0>
						</a>
					</div>

					<!-- 닫기버튼-->
					<div style="position:absolute;left:370px;top:0px;width:40px;height:40px;cursor:pointer;" onclick="$('#div_user').hide();"><span></span></div>										
				</div>
				<div id='div_memo_send' style="display:none;width:410px;height:260px;background-image:url('./img/popup_message_bg.png');">
					<br/><br/><br/><br/><br/><br/>
					<p align='center'>
					<span id="article_content">
						'<span id='memo_target_name_4'>dd</span>'님에게 쪽지가 성공적으로 전송되었습니다.<br>
					</span>
					</p>
					
					<!--a onclick="$('#div_memo_send').hide();$('#div_user_menu').show();$('#div_user').hide();" style='cursor:pointer;'>닫기</a> | <a href="memo.php?box=send" style='cursor:pointer;'>내 쪽지함 보기</a-->

					<!-- 닫기버튼-->
					<div style="position:absolute;left:370px;top:0px;width:40px;height:40px;cursor:pointer;" onclick="$('#div_user').hide();"><span></span></div>					
				</div>

			</div>


			<script>

			//친구추가
			function add_friend(target_idx, target_name)
			{
				//target_idx가 올바른 대상이 아님
				if(target_idx=="" || target_idx=="<?=$user_idx?>")
				{
					return;
				}


				 $.post(
					"friends_add.php", 
					{	
						'target_idx': target_idx
					}, 
					function (data) { 
						if(data=="0")
							//친구추가 성공
							alert("'"+target_name+"'님이 이웃에 추가되었습니다.");

						else if(data=="-1")
							//친구추가 실패 : 이미 친구임
							alert("'"+target_name+"'님과는 이미 이웃입니다.");

						else if(data=="-99")
							//친구추가 실패 : 오류
							alert("친구 추가 실패");
						
					}
				); 
			}




			function memo_send()
			{
				

				 $.post(
					"memo_send.php", //서버측 스크립트 언어
					{	'target_idx': $('#memo_new_target_idx').val() ,
						'new_comment' : $('#memo_new_content').val() 


					}, //쿼리스트링?키1=값1&키2=값2
					function (data) {         //콜백함수 : 결과값 받기 , data로 받아옴  
						//$('#pnlDisplay').html(data);
		//				$('#commentDisplay').load('my_info_main_comment.php', {'info_idx' : '<? echo $info_idx; ?>', 'user_idx' : '<? echo $user_idx; ?>', 'disease_idx' : '<? echo $disease_idx; ?>'});
		//						alert(data);
						$('#div_memo_new').hide();
						$('#div_memo_send').show();
					}
				); 

				
				try{
			
				memo_display_list(page); 
				}
				catch(err)
				{}
			

			}

			var user_menu_shift_left = 350;
			function show_user_menu(target_idx, target_name)
			{

				$('#memo_target_name_1').html(target_name);
				$('#memo_target_name_2').html(target_name);
				$('#memo_target_name_3').html(target_name);
				$('#memo_target_name_4').html(target_name);
				$('#memo_new_target_idx').val(target_idx);

				$('#div_user_menu').show();
				$('#div_memo_new').hide();
				$('#div_memo_send').hide();

				$('#div_user').css({"left":($('#e_x').val()-user_menu_shift_left)+"px"});
				$('#div_user').css({"top":$('#e_y').val()+"px"});

				$('#div_user').show();

			}

			function show_user_menu_reply(target_idx, target_name)
			{

				$('#memo_target_name_1').html(target_name);
				$('#memo_target_name_2').html(target_name);
				$('#memo_target_name_3').html(target_name);
				$('#memo_target_name_4').html(target_name);
				$('#memo_new_target_idx').val(target_idx);

				$('#div_user_menu').hide();
				$('#div_memo_new').show();
				$('#div_memo_send').hide();

				$('#memo_new_content').val("");

				$('#div_user').css({"left":($('#e_x').val()-user_menu_shift_left)+"px"});
				$('#div_user').css({"top":$('#e_y').val()+"px"});

				$('#div_user').show();
				
				$('#memo_new_content').focus();

			}

			function move_my_info()
			{
				var temp_url = 'my_info.php?info_idx='+$('#memo_new_target_idx').val(); 
				location.href=temp_url;
			}

			jQuery(document).ready(function(){
			   $(document).mousemove(function(e){
				  $('#e_x').val(e.pageX);
				  $('#e_y').val(e.pageY);
			   }); 
			})
			
			</script>

			<input type='hidden' id="e_x">
			<input type='hidden' id="e_y">



		<!-- 개인 팝업 메뉴 끝-->